home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / BIDSAPI.PAK / MYCLASS.CPP next >
C/C++ Source or Header  |  1997-05-06  |  2KB  |  108 lines

  1. // ---------------------------------------------------------------------------
  2. // Copyright (C) 1994 Borland International
  3. //  myclass.cpp
  4. // ---------------------------------------------------------------------------
  5.  
  6. #include "..\myclass.h"
  7.  
  8. MyClass::MyClass()
  9. {
  10.     TRACE("Empty MyClass");
  11. }
  12.  
  13. MyClass::MyClass(const string& s)
  14.     : Str(s)
  15. {
  16.     TRACE("Con string '" << Str << "'");
  17. }
  18.  
  19. MyClass::MyClass(const MyClass& mc)
  20.     : Str(mc.Str)
  21. {
  22.     TRACE("Copy string '" << Str << "'");
  23. }
  24.  
  25. MyClass::~MyClass()
  26. {
  27.     TRACE("Des string '" << Str << "'");
  28. }
  29.  
  30. MyClass& MyClass::operator=(const MyClass& mc)
  31. {
  32.     Str = mc.Str;
  33.     return *this;
  34. }
  35.  
  36. int MyClass::operator==(const MyClass& mc) const
  37. {
  38.     return Str == mc.Str;
  39. }
  40.  
  41. int MyClass::operator<(const MyClass& mc) const
  42. {
  43.     return Str < mc.Str;
  44. }
  45.  
  46. unsigned MyClass::HashValue() const
  47. {
  48.     return Str.hash();
  49. }
  50.  
  51. ostream& operator<<(ostream& os, const MyClass mc)
  52. {
  53.     return os << "'" << mc.Str << "' hash = " << mc.HashValue();
  54. }
  55.  
  56. // 
  57. // MyValue
  58. // 
  59. MyValue::MyValue()
  60. {
  61.     TRACE("Empty MyValue");
  62. }
  63.  
  64. MyValue::MyValue(const string& s)
  65.     : Str(s)
  66. {
  67.     TRACE("Con string '" << Str << "'");
  68. }
  69.  
  70. MyValue::MyValue(const MyValue& mv)
  71.     : Str(mv.Str)
  72. {
  73.     TRACE("Copy string '" << Str << "'");
  74. }
  75.  
  76. MyValue::~MyValue()
  77. {
  78.     TRACE("Des string '" << Str << "'");
  79. }
  80.  
  81. MyValue& MyValue::operator=(const MyValue& mv)
  82. {
  83.     Str = mv.Str;
  84.     return *this;
  85. }
  86.  
  87. int MyValue::operator==(const MyValue& mv) const
  88. {
  89.     return Str == mv.Str;
  90. }
  91.  
  92. int MyValue::operator<(const MyValue& mv) const
  93. {
  94.     return Str < mv.Str;
  95. }
  96.  
  97. unsigned MyValue::HashValue() const
  98. {
  99.     return Str.hash();
  100. }
  101.  
  102.  
  103. ostream& operator<<(ostream& os, const MyValue mv)
  104. {
  105.     return os << "'" << mv.Str << "' hash = " << mv.HashValue();
  106. }
  107.  
  108.